package com.yoooya.base.third.model.vo.cp.messagebuilder;


import com.yoooya.base.third.common.WxConsts;
import com.yoooya.base.third.model.vo.cp.WxCpMessage;

/**
 * @创建人 Sun Yijing
 * @创建时间 2018-07-08
 */
public class BaseBuilder<T> {
	protected String msgType;
	protected String agentId;
	protected String toUser;
	protected String toParty;
	protected String toTag;
	protected String safe;

	public T agentId(String agentId) {
		this.agentId = agentId;
		return (T) this;
	}

	public T toUser(String toUser) {
		this.toUser = toUser;
		return (T) this;
	}

	public T toParty(String toParty) {
		this.toParty = toParty;
		return (T) this;
	}

	public T toTag(String toTag) {
		this.toTag = toTag;
		return (T) this;
	}

	public T safe(String safe) {
		this.safe = safe;
		return (T) this;
	}

	public WxCpMessage build() {
		WxCpMessage m = new WxCpMessage();
		m.setAgentid(this.agentId);
		m.setMsgtype(this.msgType);
		m.setTouser(this.toUser);
		m.setToparty(this.toParty);
		m.setTotag(this.toTag);
		m.setSafe((this.safe == null || "".equals(this.safe)) ? WxConsts.CUSTOM_MSG_SAFE_NO
				: this.safe);
		return m;
	}

}
